% this code is used to check the network using the data of input

total_num=10000;
idx=randperm(total_num,20);
sizex=28;
sizey=28;
% idx=27;
% for i = 1: numel(idx)
%     subplot(4,5,i);
%     output2D=norm_mat(reshape(output_minus(:,idx(i)),54,98));
% %     output2D=reshape(output_minus_norm(:,idx(i)),54,98);
%     imshow(output2D)
%     title('Output_minus')
% end
for i = 1: numel(idx)
    subplot(4,5,i);
    target=image_input_fft(:,:,2,idx(i)).*exp(1i.*2.*pi.*...
    (image_input_fft(:,:,1,idx(i))-0.5));
    imagesc(abs(ifft2(target)))
    title('Input')
end

figure
for i = 1: numel(idx)
    subplot(4,5,i);
    
    
    Phase=(reshape(output_fft(1:sizex*sizey,idx(i)),sizex,sizey)-0.5).*pi.*2;
    Amp=reshape(output_fft(sizex*sizey+1:end,idx(i)),sizex,sizey);
%     output2D=reshape(output_minus_norm(:,idx(i)),54,98);
    imagesc(abs(ifft2(Amp.*exp(1i.*Phase))))
    title('Output')
end
figure
for i = 1: numel(idx)
    subplot(4,5,i);
    Predicted=predict(net_minus,image_input_fft(:,:,:,idx(i)));
    
    Phase=reshape(Predicted(1:sizex*sizey),sizex,sizey);
    Amp=reshape(Predicted(sizex*sizey+1:end),sizex,sizey);
%     Amp=reshape(Amp,sizex,sizey);
    Phase=(reshape(Phase,sizex,sizey)-0.5).*pi.*2;
%     Predicted2D=norm_mat(Amp);
    imagesc(abs(ifft2(Amp.*exp(1i.*Phase))))
    title('Predicted')
end
